/*
 * @Author: yc
 * @Date: 2020-05-26 20:02:36
 * @LastEditTime: 2020-05-26 20:05:42
 * @FilePath: \react-admin\src\index.js
 */
import React, { Suspense } from 'react'
import { render } from 'react-dom'
import { BrowserRouter as Router, Redirect, Switch, Route } from 'react-router-dom'
import { Spin } from 'antd'
import { Provider } from 'react-redux'
import store from './redux/store'
import { mainRoutes } from './routes'

import App from './App'

render(
  <Provider store={store}>
    <Suspense fallback={<Spin/>} >
      <Router>
        <Switch>
          <Route path="/admin" component={App}></Route>
          {
            mainRoutes.map(route => (
              <Route key={route.pathname} path={route.pathname} component={route.component} />
            ))
          }
          <Redirect to="/admin" from="/" exact />
          <Redirect to="/404" />
        </Switch>
      </Router>
    </Suspense>
  </Provider>,
  document.getElementById('root')
)
